package com.lixianhe.onlineexam.controller;

import com.lixianhe.onlineexam.pojo.FillQuestion;
import com.lixianhe.onlineexam.service.FillQuestionService;
import com.lixianhe.onlineexam.util.ApiResultHandler;
import com.lixianhe.onlineexam.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FillQuestionController {
    @Autowired
    private FillQuestionService fillQuestionService;

    @PostMapping("fillQuestion")
    public R fillQuestion(@RequestBody FillQuestion fillQuestion) {
        int res = fillQuestionService.addFillQuestion(fillQuestion);
        if (res == 1) return ApiResultHandler.buildApiResult(200, "添加成功", res);
        return ApiResultHandler.buildApiResult(400, "添加失败", res);
    }

    @GetMapping("fillQuestionId")
    public R fillQuestionId() {
        FillQuestion fillQuestion = fillQuestionService.fillQuestionId();
        return ApiResultHandler.buildApiResult(200, "查询填空题ID", fillQuestion);
    }
}
